//弹出层封装
var doctor_out_aq_bg_01 = 0;
var doctor_out_aq_bg_02 = 0;
var doctor_out_aq_bg_03 = 0;
var doctor_out_aq_bg_04 = 0;

//关闭弹层1-答题层
function doctor_close_answer()
{
	doctor_out_aq_bg_01 = 0;
	$('.ans_backbg').remove();
	$('.ans_block').remove();
}

//弹层1-答题层
function doctor_open_answer(obj , n)
{
	var option = sysConfig.option;
	if(typeof(obj) == 'undefined')
	{
		outjs_openblock('数据加载失败，请重试！');
		return;
	}

	if(typeof(n) == 'undefined')
	{
		n = 1;
	}

	//显示背颢
	if(doctor_out_aq_bg_01 == 0)
	{
		doctor_out_aq_bg_01 = 1;
		var bghtml = '<div class="pf o_60 ans_backbg"></div>';
		$('body').append(bghtml);
	}

	//解析题库
	var question   = obj.data[0].queName;
	var ansreal    = obj.data[0].ansReal;
	if(ansreal == 'a')
	{
		right = 0;
	}
	else if(ansreal == 'b')
	{
		right = 1;
	}
	else if(ansreal == 'c')
	{
		right = 2;
	}
	else
	{
		right = 3;
	}
	var answerhtml = '';
	var ans   = '';
	for(var i = 0 ; i < 4 ; i++)
	{
		if(i == right)
		{
			var isright = 1;
		}
		else
		{
			var isright = 0;
		}
		if(i == 0)
		{
			ans = obj.data[0].ansA;
		}
		else if(i == 1)
		{
			ans = obj.data[0].ansB;
		}
		else if(i == 2)
		{
			ans = obj.data[0].ansC;
		}
		else
		{
			ans = obj.data[0].ansD;
		}
		answerhtml += '<li><a href="###" class="sel_now" t="'+i+'" isright="'+isright+'">'+ans+'</a></li>';
	}

	//显示内容
	var html = '';
	html += '<div class="pf ans_block">';
	html += '	<div class="ans_block_in pr">';
	html += '		<div class="ans_b_box ps">';
	html += '			<div class="ans_box pr">';
	html += '				<a href="###" class="ans_close ps" layer="1">X</a>';
	html += '				<div class="ans_rw ps"></div>';
	html += '				<a href="###" class="ans_search_btn ps">搜答案</a>';
	html += '				<div class="ans_box_bg ps o_90"><div class="ans_box_bg2"><div class="ans_box_bg3"></div></div></div>';
	html += '				<div class="ans_box_zbox abz_box ps">';
	html += '					<div class="ans_title">第'+n+'题（共'+option.questionmaxnum+'题）</div>';
	html += '					<div class="ans_question">'+question+'</div>';
	html += '					<div class="ans_answer">';
	html += '						<ul>';
	html +=               answerhtml;
	html += '						</ul>';
	html += '					</div>';
	html += '				</div>';
	html += '			</div>';
	html += '		</div>';
	html += '	</div>';
	html += '</div>';
	$('body').append(html);
}

//关闭弹层2-正确或错误
function doctor_close_tips()
{
	doctor_out_aq_bg_02 = 0;
	$('.ans_backbg2').remove();
	$('.ans_block2').remove();
}

//弹层2-答题正确或错误(是否正确、题的编号 )
function doctor_open_tips(isright , n)
{
	var option = sysConfig.option;
	if(n == option.questionmaxnum)
	{
		var nexthtml = '<div class="abo_btn ps"><a href="###" class="btn_next_use" layer="2">使用解药</a></div>';
	}
	else
	{
		var nexthtml = '<div class="abo_btn ps"><a href="###" class="btn_next_question" layer="2">下一题</a></div>';
	}

	//显示背颢
	if(doctor_out_aq_bg_02 == 0)
	{
		doctor_out_aq_bg_02 = 1;
		var bghtml = '<div class="pf o_80 ans_backbg2"></div>';
		$('body').append(bghtml);
	}

	var html = '';
	html += '<div class="pf ans_block2">';
	html += '	<div class="ans_block_in pr">';
	html += '		<div class="ans_b_box ps">';
	html += '			<div class="ans_box pr">';
	if(isright == 1)
	{
		html += '				<div class="ans_block_ok pr">';
		html += '					<div class="abo_txt ps"></div>';
		html += nexthtml;
		html += '				</div>';
	}
	else
	{
		html += '				<div class="ans_block_error pr">';
		html += '					<div class="abo_txt ps"></div>';
		html += '					<div class="abo_btn ps"><a href="###" class="btn_next" layer="2">再答一次</a></div>';
		html += '				</div>';
	}
	html += '			</div>';
	html += '		</div>';
	html += '	</div>';
	html += '</div>';
	$('body').append(html);
}

//关闭弹层
function doctor_close_search()
{
	doctor_out_aq_bg_03 = 0;
	$('.ans_backbg3').remove();
	$('.ans_block3').remove();
}

//弹层3-获取搜索
function doctor_open_search()
{
	//显示背颢
	if(doctor_out_aq_bg_03 == 0)
	{
		doctor_out_aq_bg_03 = 1;
		var bghtml = '<div class="pf o_80 ans_backbg3"></div>';
		$('body').append(bghtml);
	}

	var html = '';
	html += '<div class="pf o_80 ans_backbg3"></div>';
	html += '<div class="pf ans_block3">';
	html += '  <div class="ans_block_in pr">';
	html += '    <div class="ans_b_box ps">';
	html += '      <div class="ans_rw3 ps"></div>';
	html += '      <a href="###" class="ans_close3 ps" layer="3">X</a>';
	html += '      <div class="ans_search"><input id="searchInp" type="text" class="search_inp" placeholder="请输入检索内容，特点词会增加准确度" ></div> ';
	html += '      <div class="ans_lian pr">';
	html += '        <div class="al_lian al_left ps"></div>';
	html += '        <div class="al_lian al_right ps"></div>';
	html += '      </div>';
	html += '      <div class="ans_search_txt ps">';
	html += '        <div class="ast_nolist">填入关键词，点博士搜一下吧！</div>';
	html += '        <div id="searchResult" class="ast_list">';
	html += '        </div>';
	html += '      </div>';
	html += '    </div>';
	html += '  </div>';
	html += '</div>';
	$('body').append(html);
}

//关闭弹层-4
function doctor_open_search_out_close()
{
	doctor_out_aq_bg_04 = 0;
	$('.ans_backbg4').remove();
	$('.ans_block4').remove();
}

//弹层4-搜索弹出层
function doctor_open_search_out()
{
	//显示背颢
	if(doctor_out_aq_bg_04 == 0)
	{
		doctor_out_aq_bg_04 = 1;
		var bghtml = '<div class="pf o_80 ans_backbg4"></div>';
		$('body').append(bghtml);
	}
	var html = '';
	html += '<div class="pf ans_block4">';
	html += '	<div class="ans_block_in pr">';
	html += '		<div class="ans_b_box ps">';
	html += '			<div class="ans_box pr">';
	html += '				<a href="###" class="ans_close4 ps" layer="4">X</a>';
	html += '				<div class="ans_rw4 ps"></div>';
	html += '				<div class="ans_box_bg ps o_90"><div class="ans_box_bg2"><div class="ans_box_bg3"></div></div></div>';
	html += '				<div class="ans_box_zbox outsearchhtml ps">';
	html += '				</div>';
	html += '			</div>';
	html += '		</div>';
	html += '	</div>';
	html += '</div>';

	$('body').append(html);
}

//追加内容
function doctor_open_search_html(tit , hbody)
{
	var html = '';
	if(tit != '')
	{
		html += '<div class="search_title">'+tit+'</div>';
	}
	if(hbody != '')
	{
		html += '<div class="search_body">'+hbody+'</div>';
	}
	$('.outsearchhtml').html(html);
}

//GAME OVER
function doctor_gameover()
{
	var html = '';
	html += '<div class="pf o_80 ans_backbg5"></div>';
	html += '<div class="pf ans_block5">';
	html += '	<div class="ans_block_in pr">';
	html += '		<div class="ans_b_box ps">';
	html += '			<div class="ans_box pr">';
	html += '				<div class="ans_block_error pr">';
	html += '					<div class="abo_txt3 ps"></div>';
	html += '					<div class="abo_btn ps"><a href="###" class="btn_to_rank" layer="5" onclick="toRank();">看看排行</a></div>';
	html += '				</div>';
	html += '			</div>';
	html += '		</div>';
	html += '	</div>';
	html += '</div>';
	$('body').append(html);
}


